package demo;

//线程安全
public class Demo2 extends Thread {

    //此处定义一个int类型的变量
    private static int count = 0;

    @Override
    public void run() {
        synchronized (Demo2.class) {
            for( count = 0; count <= 200; count++ ) {
                System.out.println(count);
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {


        Thread t1 = new Demo2();
        Thread t2 = new Demo2();

        t1.start();
        t2.start();


    }

}
